# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo05
# Description:
# Author:       98745
# Date:         2019/3/3
#-------------------------------------------------------------------------------

class FD:
    def __init__(self):
        self.nd={}
    def f(self,n):
        if n==0 or n==1:
            return 1
        else:
            return n*self.f(n-1)
    def __getitem__(self, key):
        print('getitem方法被调用，key={}'.format(key))
        if key in self.nd:
            return self.f(self.nd[key])
        else:
            return 0
    def __setitem__(self, key, value):
        print('seritem方法被调用了：key={}'.format(key))
        self.nd[key]=int(value)
    def __delitem__(self, key):
        print('delitem方法被调用了，key={}'.format(key))
        del self.nd[key]
    def __len__(self):
        print('len方法被调用了')
        return len(self.nd)
d=FD()
d['4!']=4
d['7!']=7
d['12!']='12'
print('4!','=',d['4!'])
print('7!','=',d['7!'])
print('12!','=',d['12!'])
print('len','=',len(d))
del d['7!']
print('7!','=',d['7!'])
print('len','=',len(d))